<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2018/10/30
  Time: 16:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String imgPath = request.getServletContext().getRealPath("/productImages");
%>
<html>
<head>
    <title>详细列表</title>
    <link rel="stylesheet" href="<%=path%>/resources/css/font.css">
    <link rel="stylesheet" href="<%=path%>/resources/css/xadmin.css">
    <script type="text/javascript" src="<%=path%>/resources/js/jquery.min.js"></script>
    <script type="text/javascript" src="<%=path%>/resources/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=path%>/resources/js/x-layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=path%>/resources/js/xadmin.js"></script>
</head>
<body class="layui-anim layui-anim-up">
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">订单管理</a>
            <a>
              <cite>详细列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:40px">&#xe669;</i></a>
</div>
<div class="x-body">
    <div class="layui-form x-center" style="width:100%">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label">订单号</label>
                <div class="layui-input-inline">
                    <input type="text" name="orderNo" id="orderNo" placeholder="请输入订单号"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">用户Id</label>
                <div class="layui-input-inline">
                    <input type="text" name="userId" id="userId" placeholder="请输入用户Id"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">商品Id</label>
                <div class="layui-input-inline">
                    <input type="text" name="productId" id="productId" placeholder="请输入商品Id"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="productName" id="productName" placeholder="请输入商品名称"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline" style="width:80px">
                    <button class="layui-btn" data-type="reload" id="check">搜索</button>
                </div>
            </div>
        </div>
    </div>
    <table type="layui-hide" id="orderDetailTable" lay-filter="orderDetailTable"></table>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="updatePwd">导出</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
<script>
    layui.use([ 'table' ], function() {
        var table = layui.table;

        table.render({
            elem: '#orderDetailTable'
            ,limit:5
            ,url:"<%=path%>/order/getOrderDetailListPage"
            ,page: true
            ,toolbar: '#toolbarDemo'
            ,cols: [[
                {type:'checkbox', fixed: 'left'}
                ,{field:'orderNo', title: '订单号'}
                ,{field:'productId', title: '商品ID'}
                ,{field:'productName', title: '商品名称'}
                ,{field:'userId', title: '用户ID'}
                ,{field:'productNumber', title: '购买数量'}
                ,{field:'productTotalprice', title: '商品总价'}
                ,{fixed:'right', title:'操作', toolbar: '#barDemo',width:180}
            ]]
        });
        $('#check').click(function(){
            table.reload('orderDetailTable', {
                page:{
                    curr:1
                },
                where: {
                    //设定异步数据接口的额外参数，任意设
                    orderNo:$('#orderNo').val(),
                    userId:$('#userId').val(),
                    productId:$('#productId').val(),
                    productName:$('#productName').val()
                }
            });
        });
        table.on('tool(orderDetailTable)', function(obj){
            var data = obj.data;
            if(obj.event == 'edit'){
                x_admin_show('编辑','<%=path%>/order/updateOrderDetailHtm?orderDetailId='+data.orderDetailId,700,600);
            }
        });
    });

    function order_excel(id){
        layer.confirm('确认要导出吗？',function(index){
            $.get("<%=path%>/order/excelOrder?orderDetailId="+id,function(data){
                if(data=="success"){
                    layer.msg('导出成功!', {
                        icon : 6,
                        time : 1000
                    });
                }else{
                    layer.msg('导出失败!', {
                        icon : 1,
                        time : 1000
                    });
                }
            });
        });
    }



    function delAll (argument) {

        var data = tableCheck.getData();

        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
    }


</script>
</body>
</html>
